//
//  CoreDataManager.h
//  Droplets
//
//  Created by 米明 on 15/2/9.
//  Copyright (c) 2015年 米明. All rights reserved.
//

#import "LYObject.h"
#import "Task.h"
#import "UploadTask.h"
#import "UpGoods.h"
@interface CoreDataManager : LYObject
//管理对象模型
@property(nonatomic,retain)NSManagedObjectModel * objcModel;
//持久化数据存储协调器
@property(nonatomic,retain)NSPersistentStoreCoordinator * coordinator;
//托管对象上下文
@property(nonatomic,retain)NSManagedObjectContext * objcContext;


+(CoreDataManager *)shareManager;

-(void)saveContext;

-(NSManagedObjectContext *)managedObjectContext;

-(void)deleteObjectModel:(NSManagedObject *)model;

-(NSArray *)getModels:(NSString *)objcName;

-(void)addTask:(UploadTask *)task;

-(void)deleteTaskByPhotoPath:(NSString *)photoPath;

-(void)taskDoneWithPhotoPath:(NSString *)photoPath;

-(NSMutableArray *)tasks;

-(void)deleteAllTask;

-(void)deleteDoneTask;

-(BOOL)isHasTaskByPhotoPath:(NSString *)photoPath;

-(int )maxNumberWithGoodsId:(NSString *)goodsId;

/**
 *  最近的任务商品列表
 */

-(BOOL)isHasGoodsByGoodsId:(NSString *)goodsId;
-(void)addGoods:(Goods *)goods;
-(void)deleteGoods:(Goods *)goods;
-(NSMutableArray *)goodsList;
-(void)clearGoods;

@end
